#ifndef H_USERS_20080209
#define H_USERS_20080209

#include "macros.h"
#include "types.h"
#include "net.h"

#define 	USERLEVEL_NONE  0x01
#define 	USERLEVEL_MAST	0x02
#define 	USERLEVEL_ADM	0x04
#define 	USERLEVEL_OP	0x08

#define		USER_ISMASTER(user)	(user->level & USERLEVEL_MAST)
#define		USER_ISADMIN(user)	(user->level & USERLEVEL_ADM)
#define		USER_ISOP(user)		(user->level & USERLEVEL_OP)
#define		USER_ISNOLEVEL(user)(user->level & USERLEVEL_NONE)

#define		USER_STATE_SPECT		0x01
#define 		USER_STATE_PLAY		0x02
#define 		USER_STATE_AWAY		0x03

#define		make_user_spectate(user)		(user->status = SPECT)
#define		make_user_play(user)			(user->status = PLAY)
#define		make_user_away(user)		(user->status = AWAY)


int client_init_hashtable (void);
int client_compare (void* E1, void* E2);
int client_get_hash	(HashTable* htb, void* element);
void client_del (const char* user);

Client* client_new (int sock, char nick[NICKSIZE], char user[USERSIZE], char host[HOSTSIZE], int level);

Peer* peer_new (struct sockaddr_in sin, int Socket);
void peer_clear (Peer **peer);

void client_chan_add (Client* client, const char* chname);
void client_chan_del (Client* client, const char* chname);

#endif

